package com.message.feignclient;

import com.alibaba.fastjson.JSON;
import com.base.model.R;
import com.message.model.Media;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * @Author: 小何
 * @Description: TODO
 * @DateTime: 2023/9/27 15:50
 **/
@Slf4j
public class MediaSearchClientFactory implements FallbackFactory<MediaSearchClient> {

    Logger logger= LoggerFactory.getLogger(MediaSearchClientFactory.class);

    @Override
    public MediaSearchClient create(Throwable throwable) {
        return new MediaSearchClient() {

            @Override
            public R<String> saveMedia(Media media) {
                logger.error("es文档添加失败,media信息为:"+ JSON.toJSONString(media));
                return R.error("es文档添加失败");
            }
        };
    }
}
